package com.loong.mapper;

import com.loong.pojo.Item;
import com.loong.pojo.Orders;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderMapper {

    /**
     * 插入订单信息
     * @param orders 订单信息
     */
//    @Insert("insert into orders(aid,oid, uid,oprice,otime,ostate)" +
//            "values(#{orders.aid},#{orders.oid},#{orders.uid},#{orders.oprice},#{orders.otime},#{orders.ostate})")
//    void insertOrders(@Param("orders") Orders orders);
    @Insert("INSERT INTO orders(aid, oid, uid, oprice, otime, ostate) " +
            "VALUES(#{aid}, #{oid}, #{uid}, #{oprice}, #{otime}, #{ostate})")
    void insertOrders(Orders orders);

/**
 * 根据用户id查询订单信息
 * @param uid 用户id
 */
    List<Orders> selectOrderByUid(@Param("uid") Integer uid);

    /**
     *  根据订单id查询订单信息
     * @param oid 订单id
     * @return  订单信息
     */
    Orders selectOrderByOid(String oid);

    /**
     *  根据订单id更新订单状态
     * @param oid  订单id
     */
    @Update("update orders set ostate = 2 where oid = #{oid}")
    void updateStateByOid(String oid);

    /**
     *  确认收货
     * @param oid 订单id
     */
    @Update("update orders set ostate = 4 where oid = #{oid}")
    void updateStateToFourByOid(String oid);
}

